package 力扣刷题.探索初级算法.数组.旋转图像;

import java.util.Scanner;

public class Solution {
    public void rotate(int[][] matrix) {

        int row=matrix.length;
        int column=matrix[0].length;
        int[][] rotatedMatrix=new int[row][column];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                int rotatedI=j;
                int rotatedJ=column-1-i;
                rotatedMatrix[rotatedI][rotatedJ]=matrix[i][j];
            }
        }
        matrix=rotatedMatrix;
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                matrix[i][j]=rotatedMatrix[i][j];
            }
        }
        //System.out.println(Arrays.deepToString(matrix));
    }
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int row,column;
        row=s.nextInt();
        column=s.nextInt();
        int[][] matrix=new int[row][column];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                matrix[i][j]=s.nextInt();
            }
        }

       new Solution().rotate(matrix);
    }
}
